<template>
  <view class="main">
    <view class="top"
      >{{ data.content
      }}<view class="top-time">{{ getTimeDesc(data.time) }}</view></view
    >
    <view class="content">
      <text
        class="contenttext"
        :selectable="true"
        v-for="(item, index) in CovertDate()"
        :key="index"
      >
        {{ item }}
      </text>
    </view>
    <view class="bottom" v-show="lastArgs != ''" @click="todetail">
      <!-- {{ data.extend.data_args.slice(-1)[0] }} -->
      <view class="bottom-btn" :style="{ 'background-color': t('color2') }"
        >查看详情</view
      >
    </view>
  </view>
</template>

<script>
import moment from "../../moment/min/moment.min.js";
var app = getApp();
export default {
  props: {
    data: {
      type: Object,
      default: () => {},
    },
    right: Boolean,
    NewArags: [],
    lastArgs: "",
  },
  data() {
    return {};
  },
  methods: {
    CovertDate(date) {
      console.log(this.data);
      let type = Number(this.data.extend.msg_type);
      if (
        //消息卡片下发需要出现按钮的情况
        type == 6 ||
        type == 7 ||
        type == 8 ||
        type == 9 ||
        type == 11 ||
        type == 13 ||
        type == 14 ||
        type == 17 ||
        type == 18
      ) {
        this.lastArgs = this.data.extend.data_args.slice(-1)[0];
        return this.data.extend.data_args.slice(0, -1);
      }
      if (type == 10 || type == 12) {
        return this.data.extend.data_args;
      }
    },

    todetail() {
      let type = Number(this.data.extend.msg_type);
      if (type == 6) {
        //订单支付成功订阅消息
        app.goto("/pagesExt/order/detail?id=" + this.data.extend.data_id);
      }
      if (type == 7) {
        //发货订阅消息
        app.goto("/pagesExt/order/logistics?id=" + this.data.extend.data_id);
      }
      if (type == 8) {
        //订单收货成功消息
        app.goto("/pagesExt/order/comment?ogid=" + this.data.extend.data_id);
      }
      if (type == 9) {
        //退货审核通知消息
        app.goto("/pagesExt/order/refundDetail?id=" + this.data.extend.data_id);
      }
      if (type == 10) {
        //退款完成通知
      }
      if (type == 11) {
        //余额变动通知
        app.goto("/pages/money/moneylog?st=0");
      }
      if (type == 12) {
        //充值到账通知
        app.goto("/pages/money/moneylog?st=1");
      }
      if (type == 13) {
        //新佣金到账通知
        app.goto("/pagesExt/commission/commissionlog");
      }
      if (type == 14) {
        //佣金提现结果通知
        app.goto("/pagesExt/commission/commissionlog?st=1");
      }
      if (type == 17) {
        //积分奖励待领取通知
        app.get("MemberCenter/putPopupJifen", {}, (res) => {
          if (res.code == 200) {
            app.error("领取成功");
          }
        });
      }
      if (type == 18) {
        app.goto("/pagesExt/my/scorelog");
      }
    },

    getTimeDesc(stamp) {
      let time = moment(new Date(stamp * 1000)).format("YYYY-MM-DD HH:mm:ss");
      let temp = time.split(" ");
      if (moment().isSame(time, "day")) {
        temp[0] = "今天";
      } else if (moment().subtract(1, "days").isSame(time, "day")) {
        temp[0] = "昨天";
      } else if (moment().isSame(time, "year")) {
        temp[0] = moment(temp[0]).format("MM月DD日");
      } else {
        temp[0] = moment(temp[0]).format("YYYY年MM月DD日");
      }
      let hms = temp[1].split(":");
      hms.splice(2, 1);
      temp[1] = hms.join(":");
      return temp.join(" ");
    },
  },
  computed: {},
};
</script>

<style lang="scss" scoped>
.main {
  width: 70vw;
  position: relative;
  background-color: #ffffff;
  border-radius: 12rpx;
  // box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  .top {
    font-size: 29rpx;
    color: #333;
    // margin-bottom: 6rpx;
    padding: 20rpx;
    padding-bottom: 0rpx;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .top-time {
      font-size: 24rpx;
      color: #838182;
      font-weight: normal;
    }
  }
  .content {
    padding: 10rpx 20rpx;
    font-size: 24rpx;
    color: #838182;
    line-height: 40rpx;
    // border-top: #e7e7e7 1px solid;
    // border-bottom: #e7e7e7 1px solid;
    .contenttext {
      display: block;
    }
  }
  .bottom {
    font-size: 26rpx;
    color: #999;
    padding: 20rpx;
    padding-top: 10rpx;
    display: flex;
    justify-content: end;
    .bottom-btn {
      color: #ffffff;
      text-align: center;
      border-radius: 16rpx;
      padding: 4rpx 14rpx;
      border-radius: 18rpx;
    }
  }
}
</style>
